home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / FILLNUM.AML < prev    next >
Text File  |  1996-07-17  |  3KB  |  111 lines

  1. //--------------------------------------------------------------------
  2. // FILLNUM.AML
  3. // Fill Block with a numeric sequence, (C) 1993-1996 by nuText Systems
  4. //
  5. // (See Fillnum.dox for user help)
  6. //
  7. // This macro fills a column block with an incrementing or decrementing
  8. // numeric value. Note: this macro will run faster if Undo is turned
  9. // Off on Set menu.
  10. //
  11. // Usage:
  12. //
  13. // Select this macro from the Macro List (on the Macro menu), or run it
  14. // from the macro picklist <shift f12>.
  15. //--------------------------------------------------------------------
  16.  
  17. include bootpath "define.aml"
  18.  
  19. variable fillstart, fillstep, justopt
  20.  
  21. // test for edit windows
  22. if not wintype? "edit" then
  23.   msgbox "Edit windows only!"
  24.   return
  25. end
  26.  
  27. // test for mark in current window and column mark
  28. if getcurrbuf <> getmarkbuf or getmarktype <> 'k' then
  29.   msgbox "Column block not marked in current window."
  30.   return
  31. end
  32.  
  33. macrofile = arg 1
  34.  
  35. // called by Lib.x when a key is entered in the dialog box
  36. function ondialog (keycode)
  37.   // macro help
  38.   if keycode == <f1> then
  39.     helpmacro macrofile
  40.   end
  41. end
  42.  
  43. // dialog box
  44. dialog "Fill Block with Numbers" 38 8 'c'
  45. field  "&Start:  >"  3  2 12  1
  46. field  "Ste&p:   >"  3  4 12  1
  47.  
  48. // justify options
  49. groupbox '' 3 6
  50.   (menu ''
  51.      item " ( ) &Left Justify"
  52.      item " ( ) &Right Justify"
  53.    end)  20 'r' "lr"
  54.  
  55. button "O&k"        27  2  8
  56. button "Cancel"     27  4  8
  57.  
  58. // display dialog box and get user values
  59. if (getdialog ref fillstart ref fillstep ref justopt) <> 'Ok' then
  60.   return
  61. end
  62.  
  63. // check block width
  64. finish = fillstart + ((getmarkrows - 1) * fillstep)
  65. maxwidth = length finish
  66. if maxwidth < length fillstart then
  67.   maxwidth = length fillstart
  68. end
  69. markwidth = getmarkcols
  70. if maxwidth > markwidth then
  71.   msgbox "Column block must be at least " + maxwidth + " columns wide."
  72.          "Error!"
  73.   return
  74. end
  75.  
  76. if pos 'l' justopt then
  77.   markwidth = -markwidth
  78. end
  79.  
  80.  
  81. // display message
  82. say "Filling block..."
  83.  
  84. // mark the beginning of an undoable group of operations
  85. undobegin
  86.  
  87. // stop cursor movement from resizing the mark
  88. stopmark
  89.  
  90. // save cursor position and goto first line
  91. pushcursor
  92.  
  93. gotopos (getmarkleft) (getmarktop)
  94.  
  95. // enter numbers into the block
  96. loop getmarkrows times
  97.   ovltext fillstart:markwidth
  98.   fillstart = fillstart + fillstep
  99.   down
  100. end
  101. breakoff
  102.  
  103. // mark the end of an undoable group of operations
  104. undoend
  105.  
  106. // restore cursor
  107. popcursor
  108.  
  109. // clear the title bar
  110. display
  111.